package cn.edu.bjfu.practice.practice.app.configuration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

@Configuration
public class FileConfiguration implements WebMvcConfigurer {

    @Value("${case.basePath}")
    String casePath;

    @Value("${task.basePath}")
    String taskPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/file/**").addResourceLocations("file:" + casePath + '/');
        registry.addResourceHandler("/task/**").addResourceLocations("file:" + taskPath + '/');
    }
}
